<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>OR Manager</title>
<?php $this->load->helper('HTML');
echo link_tag('css/style2.css');
echo link_tag('images/favicon.ico','shortcut icon','image/x-icon');
?></head>
<?php
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=or_manager.xls");
header("Pragma: no-cache");
header("Expires: 0");
?>
<body>
               <table width="90%" border="1" cellpadding="1" cellspacing="1" id="detail" align="center">
                    <thead>
                        <tr class="detail2">
                        <th>Nama Manager</th>
                        <th>Upline</th>
                        <th>Unit</th>
                        <th>Cabang</th>
                        <?php if (count($weeks)==4)
						{ 
							$col = 4;
						} else {
							$col = 5;
						}
						?>
                        <th colspan="<?php echo $col;?>">Omset Pribadi</th>
                        <th colspan="<?php echo $col;?>">Rekrut dan Belanja Rekrut</th>
                        <th>Omset Unit</th>
                        </tr>
                   </thead>
                    <tr class="data">
                      <td align="center">&nbsp;</td>
                      <td align="center">&nbsp;</td>
                      <td align="center">&nbsp;</td>
                      <td align="center">&nbsp;</td>
                      <input type="hidden" id="week_count" value="<?php echo count($weeks)?>">
                      <?php for($i=0;$i<count($weeks);$i++):?>
    				  <td align="center"><?php echo $weeks[$i]->intid_week;?></td>
        			 <?php endfor;?>
                      
                      <?php for($i=0;$i<count($weeks);$i++):?>
    				  <td align="center"><?php echo $weeks[$i]->intid_week;?></td>
        			 <?php endfor;?>
                      <td align="center">&nbsp;</td>
                    </tr>
                    <?php
                    $no=1;
					
                    foreach($data_or_manager as $row):
					
					?>
                    <tr class="data">
                        <td align="left"><?php echo $row->strnama_dealer?></td>
                        <td align="left"><?php echo $row->strnama_upline?></td>
                        <td align="center"><?php echo $row->strnama_unit?></td>
                        <td align="center"><?php echo $row->strnama_cabang?></td>
                     <?php
            		 for($i=0;$i<count($weeks);$i++):?>
       				 <td align="center">
						<?php
                        $week_pribadi = $this->Cm_model->weeks_pribadi_or($row->intid_dealer, $weeks[$i]->intid_week,$bulan);
						if(!empty($week_pribadi[0]->total)) {
                            echo $week_pribadi[0]->total;
                        }else {
                            echo "0";
                        }
						?>
        			</td>
            		<?php endfor;?>
                    <?php
						$total_rekrut=0;
						for($i=0;$i<count($weeks);$i++):?>
						<td align="center">
								<?php
								$week_rekrut = $this->Cm_model->week_rekrut($row->strkode_dealer, $weeks[$i]->intid_week);
								
								if(!empty($week_rekrut[0]->total)) {
									$tt = $week_rekrut[0]->total;
								}else {
									$tt=0;
								}
								
								$penjualanrekrut = $this->Cm_model->penjualanrekrut_or2($row->strkode_dealer, $weeks[$i]->intid_week,$bulan);
								if(!empty($penjualanrekrut[0]->total)) {
									$pr = $penjualanrekrut[0]->total;
								}else {
									$pr=0;
								}
								 
								echo $tt."<br/>".$pr;
							   
								?>
						</td>
						<?php endfor;?>
                        <td align="center"><?php echo $row->omset_unit?></td>
                    </tr>
                    <?php endforeach;?>
                </table>
</body>
</html>
